package com.sheeran.aichat.feign.bigmodel;

import com.sheeran.aichat.dto.bigmodel.BigModelResponseDTO;
import com.sheeran.aichat.dto.bigmodel.BigModelToolsResponseDTO;
import com.sheeran.aichat.dto.bigmodel.ChatCompletionRequestDTO;
import com.sheeran.aichat.dto.bigmodel.ChatToolsRequestDTO;
import com.sheeran.aichat.feign.WrappedResponseExceptionDecodeConfig;
import com.sheeran.aichat.feign.bigmodel.fallback.BigModelFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;

import javax.validation.Valid;

/**
 * @author sheeran
 */
@FeignClient(name = "BigModelClient",
        url = "${bigmodel.host}",
        configuration = WrappedResponseExceptionDecodeConfig.class,
        fallbackFactory = BigModelFallback.class)
public interface BigModelClient {

    @PostMapping("/chat/completions")
    BigModelResponseDTO completions(@RequestHeader(value = "Authorization") String token,
                                    @Valid @RequestBody ChatCompletionRequestDTO dto);

    /**
     * Web-Search-Pro
     * 专业版联网搜索在传统搜索引擎网页抓取、排序的能力基础上，增强了意图识别，支持搜索结果的流式输出。
     * 搜索工具能更有效地结合在大语言模型应用中，提高用户获取信息的效率，并一定程度上解决大语言模型所面临的幻觉问题
     */
    @PostMapping("/tools")
    BigModelToolsResponseDTO tools(@RequestHeader(value = "Authorization") String token,
                                   @Valid @RequestBody ChatToolsRequestDTO dto);
}
